package javacode.chapter07;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Example7_3 {
    public static void main(String[] args) {
        // 多重捕获异常
        Scanner scanner = new Scanner(System.in);

        try {
            System.out.print("请输入被除数：");
            int num1 = scanner.nextInt();
            System.out.print("请输入除数：");
            int num2 = scanner.nextInt();
            System.out.println(num1 + "/" + num2 + "=" + (num1 / num2));
        }catch (InputMismatchException e){
            System.out.println("被除数和除数必须是整数！");
        }catch (ArithmeticException e){
            System.out.println("除数不能为零！");
        }catch (Exception e){
            System.out.println("遇到了其他未知的异常！");
        }finally {
            System.out.println("程序结束！");
        }
    }
}
